package Rozetka.WebDriverFactory;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import java.io.File;
import java.util.concurrent.TimeUnit;

public class WebDriverFactory {

    public static final String CHROME = "Chrome";
    public static final String FIREFOX = "Firefox";

    private static WebDriver driver;

    public static WebDriver initDriver(String browser)
    {
        if (browser.equals(FIREFOX))
        {
            driver = new FirefoxDriver();
        } else
        if (browser.equals(CHROME))
        {
            File file = new File("C:\\chromedriver.exe");
            System.setProperty("webdriver.chrome.driver",file.getAbsolutePath());
            driver = new ChromeDriver();
        }
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        return driver;
    }

}
